<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/19
 * Time: 21:36
 */
header('Content-Type:application/json');
include '../classes/logincheck.php';
include '../classes/conn.php';
$class=$_POST['class'];
$homework=$_POST['homework'];
if(islogin()!='teacher_login') {
    die('error');
}
$data=array();
$query="select * from submit where class='{$class}' and homework='{$homework}'";
$res=mysql_query($query);
while ($row=mysql_fetch_assoc($res)){
    $data[]=$row;
}
for($i=0;$i<count($data);$i++){
    $query="select name from student where num='{$data[$i]['student']}' and class='{$class}'";
    $res=mysql_query($query);
    $row=mysql_fetch_assoc($res);
    $data[$i]['stuname']=$row['name'];
}
$data=json_encode($data);
echo $data;